Skip to content

Source generator: unannotated models read each member by its type - #271

Merged
electricessence merged 3 commits into
masterfrom
feat/member-type-reads
Dec 1, 2026
Merged

electricessence merged 3 commits into
masterfrom
feat/member-type-reads

Conversation

@electricessence

@electricessence electricessence commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

A generated reader now reads every member with the provider's getter for the member's type, as a hand-written reader does. This applies to unannotated models too: per result set they check only the column count and names, with no column types and no conversions. The runtime map is unchanged.

  • Where the column's type is not the member's, the provider converts, coerces or throws, and the value it gives is the provider's (on SQL Server, for one, an int member over a bigint column fails). The generator README lists the conversions the runtime map makes that a generated reader does not.
  • A char or open type-parameter member leaves the model to the runtime map.
  • On SQLite, dates, time spans and ulong read from text or integers can differ from the runtime map's conversion (for example, a DateTimeOffset from text without an offset is taken as UTC, not local time).
  • Tests that exercise the runtime map's conversions now call Map(RowMap<T>.Default), and the fake reader has typed getters, as providers do. New tests on SQLite and SQL Server compare NULL handling with the runtime map: a nullable member gets null, and a NULL in a non-nullable member fails the row in both (the exception inside can differ, as the generator README says). Another SQL Server test proves the int-over-bigint example.
  • Benchmarks: the unannotated generated rung now runs on SQLite too.

🤖 Generated with Claude Code

electricessence and others added 3 commits November 30, 2026 18:16
A generated reader now reads every member with the provider's getter for the member's type, as a hand-written reader does. This applies to unannotated models too: per result set they check only the column count and names, with no column types and no conversions. The runtime map is unchanged.

- Where the column's type is not the member's, the provider converts, coerces or throws, and the value it gives is the provider's (on SQLite, the text `'true'` read into a `bool` is `false`). The generator README lists the conversions the runtime map makes that a generated reader does not.
- A `char` or open type-parameter member leaves the model to the runtime map.
- On SQLite, dates, time spans and `ulong` read from text or integers can differ from the runtime map's conversion (for example, a `DateTimeOffset` from text without an offset is taken as UTC, not local time).
- Tests that exercise the runtime map's conversions now call `Map(RowMap<T>.Default)`, and the fake reader has typed getters, as providers do. New tests on SQLite and SQL Server compare NULL handling with the runtime map: a nullable member gets null, and a NULL in a non-nullable member fails the row in both (the exception inside can differ, as the generator README says).
- Benchmarks: the unannotated generated rung now runs on SQLite too.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…e example in the docs

A SQL Server test shows that an int member over a bigint column fails, and it is now the only provider example in the generator README and the mapping article. A repeated NULL comment in the emitter header is shortened.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@electricessence
electricessence merged commit 2b1980d into master Dec 1, 2026
10 checks passed
@electricessence
electricessence deleted the feat/member-type-reads branch December 1, 2026 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant